package com.ai.common.core.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;

public class SendMessage {
	public static String sendShortMessage(String phoneStr,String str) throws Exception{
		SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
		
		String info = null;
		
		HttpClient httpclient = new HttpClient();
		PostMethod post = new PostMethod("http://sms.api.ums86.com:8899/sms/Api/Send.do");//
		post.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,"gbk");
//		post.addParameter("SpCode", "235790");
//		post.addParameter("LoginName", "wh_hjs");
//		post.addParameter("Password", "whhjs2016");
		post.addParameter("SpCode", "235790");
		post.addParameter("LoginName", "wh_hjs");
		post.addParameter("Password", "whhjs2016");
		post.addParameter("MessageContent", str);
		post.addParameter("UserNumber", phoneStr);
		post.addParameter("SerialNumber", "000000"+format.format(new Date()));
		post.addParameter("ScheduleTime", "");
		post.addParameter("ExtendAccessNum", "");
		post.addParameter("f", "1");
		httpclient.executeMethod(post);
		info = new String(post.getResponseBody(),"gbk");

		return info;
	}
}
